module.exports = function (injectors) {
    let { inputStyle } = require("./youinput")(injectors.file);
    let { mapSafeSet } = require("./utils");
    let AnuStyle = require("./replace");

    let outputstyle = injectors.outputstyle;

    function resolvePlusOutPutStyle(resolveValueFunc, media = "plus", options = {}) {
        mapSafeSet(outputstyle, media, {});
        Object.keys(inputStyle).forEach(function (selector) {
            var props = Object.keys(inputStyle[selector]);
            if (props.length > 0) {
                props.forEach(function (prop) {
                    var ret = {
                        value: inputStyle[selector][prop]
                    };
                    runYield(resolveValueFunc, ret);
                    var handleSelector = selector;
                    if (options.hasOwnProperty("handleSelectorFunc")) {
                        handleSelector = options.handleSelectorFunc(selector);
                    }
                    var handleProp = prop;
                    if (options.hasOwnProperty("handlePropFunc")) {
                        handleProp = options.handlePropFunc(prop);
                    }
                    mapSafeSet(outputstyle[media], handleSelector, handleProp, ret.value);
                });
            }
        });
    }


    function runYield(yieldfunc, value) {
        var iterator = yieldfunc(value);
        while (!iterator.next().done) {
        }
    }

    return {
        resolvePlusOutPutStyle
    };
};